package com.hmall.user.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hmall.user.domain.dto.AddPermissionDTO;
import com.hmall.user.domain.po.SysPermissions;
import com.hmall.user.service.SysPermissionsService;
import com.hmall.user.mapper.SysPermissionsMapper;
import org.springframework.stereotype.Service;

/**
* @author yangfeng
* @description 针对表【sys_permissions】的数据库操作Service实现
* @createDate 2024-12-17 16:36:29
*/
@Service
public class SysPermissionsServiceImpl extends ServiceImpl<SysPermissionsMapper, SysPermissions>
    implements SysPermissionsService{

    @Override
    public Boolean addPermission(AddPermissionDTO dto) {
        SysPermissions permissions = new SysPermissions();
        String name = dto.getRequestMethod()+"-"+dto.getRequestPath();
        permissions.setName(name);
        if(StrUtil.isNotBlank(dto.getDescription())){
            permissions.setDescription(dto.getDescription());
        }
        return save(permissions);
    }
}




